#include <iostream>
#include <string>
#include "IncidentLogDatabase.h"


int main(int argc, char* argv[])
{
    std::string strUrl = "/clientlog/procincident";
    std::string strLog = "{\"HostGuid\":\"9801a7ed-9458-0000-0000-000000000000\",\"HostName\":\"synideMac - mini.local\"}";

    bool bRet = IncidentLogDatabase::GetInstance()->Initialize("IncDatabase.db");
    if (!bRet)
    {
        std::cout << "IncidentLogDatabase::GetInstance()->Initialize failed" << std::endl;
        return -1;
    }

    if (!IncidentLogDatabase::GetInstance()->AddIncidentLog(strUrl, strLog))
    {
        std::cout << "IncidentLogDatabase::GetInstance()->AddIncidentLog" << std::endl;
        return -1;
    }

    strUrl += "1";
    strLog += "1";
    if (!IncidentLogDatabase::GetInstance()->AddIncidentLog(strUrl, strLog))
    {
        std::cout << "IncidentLogDatabase::GetInstance()->AddIncidentLog" << std::endl;
        return -1;
    }


    strUrl += "2";
    strLog += "2";
    if (!IncidentLogDatabase::GetInstance()->AddIncidentLog(strUrl, strLog))
    {
        std::cout << "IncidentLogDatabase::GetInstance()->AddIncidentLog" << std::endl;
        return -1;
    }

    strUrl += "3";
    strLog += "3";
    if (!IncidentLogDatabase::GetInstance()->AddIncidentLog(strUrl, strLog))
    {
        std::cout << "IncidentLogDatabase::GetInstance()->AddIncidentLog" << std::endl;
        return -1;
    }

    IncidentLogDatabase::GetInstance()->GetData(strUrl);

    strUrl = "/clientlog/procincident";
    strLog += "4";
    if (!IncidentLogDatabase::GetInstance()->AddIncidentLog(strUrl, strLog))
    {
        std::cout << "IncidentLogDatabase::GetInstance()->AddIncidentLog" << std::endl;
        return -1;
    }

    strLog += "5";
    if (!IncidentLogDatabase::GetInstance()->AddIncidentLog(strUrl, strLog))
    {
        std::cout << "IncidentLogDatabase::GetInstance()->AddIncidentLog" << std::endl;
        return -1;
    }

    IncidentLogDatabase::GetInstance()->CountByUrl(strUrl);


    IncidentLogDatabase::GetInstance()->GetTopData(strUrl, 2);


    IncidentLogDatabase::GetInstance()->UpdateTopData(strUrl, 2);

    IncidentLogDatabase::GetInstance()->DeleteData(1);

    
    strUrl = "/clientlog/procincident1";
    if (!IncidentLogDatabase::GetInstance()->DeleteData(strUrl))
    {
        std::cout << "IncidentLogDatabase::GetInstance()->DeleteData" << std::endl;
    }

    IncidentLogDatabase::GetInstance()->GetData(strUrl);

    //IncidentLogDatabase::GetInstance()->ClearDataBase();
    
    return 0;
}